package com.load.objects;

import java.util.*;

public class MethodWrapper {

	private Integer id;

	private String content = "";

	private List<String> variables = new ArrayList<String>();

	public MethodWrapper(Integer id, String content) {
		this.id = id;
		this.content = content;
	}

	public MethodWrapper(String content, List<String> variables) {
		this.content = content;
		this.variables = variables;
	}

	public Integer getId() {
		return id;
	}

	public String getContent() {
		return content;
	}

	public List<String> getVariables() {
		return variables;
	}

	public void setVariables(List<String> variables) {
		this.variables = variables;
	}

	public boolean accessField(String field) {
		boolean accessWithThis = content.contains("this." + field);
		boolean containsString = content.contains(" " + field) || content.contains("(" + field) || content.contains(field + ")") || content.contains("[" + field) || content.contains(field + "]");
		boolean useField = containsString && !variables.contains(field);

		return accessWithThis || useField;
	}

	@Override
	public String toString() {
		return "MethodWrapper [id=" + id + ", content=" + content + ", variables=" + variables + "]";
	}

}